package org.tony.spider.code.novel;

import java.util.Queue;
import java.util.concurrent.LinkedBlockingQueue;

import junit.framework.TestCase;

import org.tony.spider.novel.entries.Chapter;
import org.tony.spider.novel.entries.NovelQueue;

public class NovelQueueDemo extends TestCase
{
  public void testDelete() throws InterruptedException
  {
    new Thread(new Runnable() {

      public void run()
      {
        NovelQueue nq = NovelQueue.getInstance();
        Queue<Chapter> chapters = new LinkedBlockingQueue<Chapter>();
        for (int i = 1; i <= 10; i++)
        {
          Chapter c = new Chapter();
          c.setTitle("chapter " + i);
          chapters.add(c);
        }
        nq.append("demo", chapters);

        Queue<Chapter> test = nq.poll("demo");

        for (int i = 0; i < 5; i++)
        {
          System.out.println(test.poll().getTitle());
        }

      }
    }).start();
    Thread.sleep(10 * 60 * 1000);
  }
}
